<template>
  <div class="axios">
    <h1>This is Axios</h1>
    <el-form ref="searchForm" label-width="100px"
             size="small" align="right">
      <el-row class="label-first" :gutter="24" align="center">
        <el-col :span="10">
          <el-form-item label-width="0px"></el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item label-width="0px" align="center">
            <el-button type="primary" size="small" @click="search()"
                       icon="el-icon-search">查询
            </el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>
<script>
import axios from 'axios';

export default {
  name: 'Axios', // 文件命名
  data() {
    return {};
  },
  methods: {
    search() {
      axios.post('/user', {
        firstName: 'Fred',
        lastName: 'Flintstone',
      })
        .then((response) => {
          console.log(response);
        })
        .catch((error) => {
          console.log(error);
        });
    },
  },
};
</script>
